﻿CREATE PROCEDURE [dbo].[yaf_user_nntp](
                @BoardID  INT,
                @UserName NVARCHAR(50),
                @Email    NVARCHAR(50))
AS
    BEGIN
        DECLARE  @UserID INT
        SET @UserName = @UserName + ' (NNTP)'
        SELECT @UserID = UserID
        FROM   yaf_User
        WHERE  BoardID = @BoardID
        AND Name = @UserName
        IF @@ROWCOUNT < 1
        BEGIN
            EXEC yaf_user_save
                 0 ,
                 @BoardID ,
                 @UserName ,
                 '-' ,
                 @Email ,
                 NULL ,
                 'Usenet' ,
                 NULL ,
                 0 ,
                 NULL ,
                 NULL ,
                 NULL ,
                 1 ,
                 NULL ,
                 NULL ,
                 NULL ,
                 NULL ,
                 NULL ,
                 NULL ,
                 NULL ,
                 0 ,
                 NULL
            -- The next one is not safe, but this procedure is only used for testing
            SELECT @UserID = MAX(UserID)
            FROM   yaf_User
        END
        SELECT UserID = @UserID
    END


